<?

/**
* Global html helper functions
*
* @author Adesanto Asman
* @version 1.0
* @license Free
* @package CGHtml
*
*/

/**
* Html helpers
*
* @package CGHtml
*
*/
class CGHtml{

  //-----------------------------------------------------------------------------
  /**
  * Html helper
  *
  */

  /**
   * html title
   *
   * @param string  $titleName
   * @return string
   */
  function title($titleName){

    return "<title> ".$titleName." </title>";
  }

  /**
  * init the content of drop down
  *
  * @param  array   $thisList     the array of content
  * @param  string  $thisVar      the current selected
  * @param  array   $retContent
  *
  */
  function initDropDownContent(&$thisList,
                               $thisVar,
                               &$retContent){

    $thisOptList  =	"";

    foreach($thisList as $list){

    	if($thisVar == $list){

    		$selme = "selected";
    	}else{

    		$selme = "";
    	}

    	$thisOptList .= "\n <OPTION VALUE='$list' $selme >$list \n ";
    }

    unset($list);

    $retContent = $thisOptList;

  }

  /**
  * the drop down form
  *
  * @param    string  $varName    this form name
  * @param    string  $stdPrp     properties of this form
  * @param    array   $thisList   the array of content
  * @param    string  $thisVar    the current selected
  * @return   string
  *
  */
  function formDropDown($varName,
                        $thisVar,
                        $thisList,
                        $stdPrp){

    $thePrp = &$stdPrp;

    self::initDropDownContent($thisList,
                		          $thisVar,
                		          $optList);

    return " <select name='".$varName."' ".$thePrp.">	".$optList." </select> ";
  }

  /**
  * Input box type text
  *
  * @param    string  $varName    this form name
  * @param    string  $varValue   the value
  * @param    string  $stdPrp     properties of this form
  * @return   string
  *
  */
  function formInput($varName,
                     $varValue,
                     $thePrp){

    return " <input type='text' name='".$varName."' value='".$varValue."' ".$thePrp."> ";
  }

  /**
  * Input box type submit
  *
  * @param    string  $varName    this form name
  * @param    string  $varValue   the value
  * @param    string  $stdPrp     properties of this form
  * @return   string
  *
  */
  function formSubmit($varName,
                      $varValue,
                      $thePrp){

    return " <input type='submit' name='".$varName."' value='".$varValue."' ".$thePrp."> ";
  }

  /**
  * Input box type hidden
  *
  * @param    string  $varName    this form name
  * @param    string  $varValue   the value
  * @param    string  $stdPrp     properties of this form
  * @return   string
  *
  */
  function formHidden($varName,
                      $varValue){

    return " <input type='hidden' name='".$varName."' value='".$varValue."'> ";
  }

  /**
  * Input check box
  *
  * @param    string    $varName  this form name
  * @param    string    $varValue
  * @param    string    $stdPrp   properties of this form
  * @return   string
  *
  */
  function formCheckBox($varName,
                        $varValue,
                        $thePrp){

    return " <input type='checkbox' name='".$varName."' value='".$varValue."' ".$thePrp."> ";
  }

  /**
  * Input button
  *
  * @param    string    $varLabel this button label
  * @param    string    $varName  this form name
  * @param    string    $varValue
  * @param    string    $stdPrp   properties of this form
  * @return   string
  *
  */
  function formInputButton($varLabel,
                           $varName,
                           $varValue,
                           $thePrp){

    return " <button type='submit' name='".$varName."' value='".$varValue."' ".$thePrp."> ".$varLabel." </button> ";
  }


  function actionIcon($alt,
                      $varName,
                      $width,
                      $height,
                      $srcIcon,
                      $funcName){

    if($funcName == NULL){

      return " <a href=# ".$varName." >
                <img src='".$srcIcon."'
                     width='".$width."'
                     height='".$height."'
                     ".$alt." >
               </a> ";
    }else{

      return " <a href='javascript:".$funcName."' ".$varName." >
                <img src='".$srcIcon."'
                     width='".$width."'
                     height='".$height."'
                     ".$alt." >
               </a> ";
    }
  }

  /**
  * create text area
  *
  * @param  string  $varName
  * @param  string  $varValue
  * @param  string  $thePrp
  *
  */
  function formTextArea($varName,
                        $varValue,
                        $thePrp){

    return " <textarea type='text'
                       name='".$varName."'
                       ".$thePrp." >".$varValue."</textarea> ";
  }

  /**
  * add row and colspan number
  *
  * @param  integer $rowSpan
  * @param  integer $colSpan
  *
  */
  function rowColSpan($rowSpan, $colSpan){

    return " rowspan='".$rowSpan."' colspan='".$colSpan."' ";
  }

  /**
  * Create radio button
  *
  * @param    string    $varName  this form name
  * @param    string    $varValue
  * @param    string    $stdPrp   properties of this form
  * @return   string
  *
  */
  function formRadio($varName,
                     $varValue,
                     $thePrp){

    return " <input type='radio' name='".$varName."' value='".$varValue."' ".$thePrp.">\n";
  }

  /**
  * check if this input box previously checked
  *
  * @param  boolean $isTrue
  * @param  string  $srcValue
  * @return string  CHECKED or NULL
  *
  */
  function isChecked($isTrue, $srcValue){

    if($isTrue){

      if($srcValue){

        return " checked ";
      }else{

        return " ";
      }
    }else{

      return " ";
    }
  }

  /**
  * input password
  *
  * @param    string  $varName    this form name
  * @param    string  $varValue   the value
  * @param    string  $stdPrp     properties of this form
  * @return   string
  *
  */
  function formInputPwd($varName,
                        $varValue,
                        $stdPrp){

    return " <input type='password' name='".$varName."' value='".$varValue."'> ";
  }

  /**
   * Input Upload file
   *
   * @param string  $varLabel
   * @param string  $varName
   * @param string  $maxSize
   * @return string
   */
  function formInputUploader($varLabel,
                             $varName,
                             $maxSize){

    return  " ".$varLabel." : <input name='".$varName."' type='file' ".$thePrp." >\n ".
            " <input type='hidden' name='MAX_FILE_SIZE' value='".$maxSize."' />\n ";
  }

}
?>